"""
编写人:陈强
"""
# 引入模块
from ecshop.MY_ECShop.common.base import Base,create_loading_browser
import time

# 创建一个充值类
class PageVipTopUp(Base):
    # 定义属性
    url = "http://localhost:8080/ecshop/admin/index.php"  # 网址
    vip_manage = ("class name", "icon-members")  # 会员管理
    top_button = ('css selector','a[href="user_account.php?act=list"]')
    add_apply = ('css selector','a[href="user_account.php?act=add"]')
    vip_name = ('name','user_id')
    money = ('name','amount')
    pay_select = ('name','payment')
    top_up = ('xpath','/html/body/div[3]/form/table/tbody/tr[4]/td[2]/input[1]')
    with_draw = ('xpath','/html/body/div[3]/form/table/tbody/tr[4]/td[2]/input[2]')
    to_state = ('xpath','/html/body/div[3]/form/table/tbody/tr[7]/td[2]/input[2]')
    sure = ('class name','button')
    text = ('xpath','//*[@id="listDiv"]/table[1]/tbody/tr[2]/td[6]')
    # 定义方法
    """确定网页"""
    def page_top_open_web(self):
        self.base_open_web(self.url)
    """进入iframe标签"""
    def page_top_iframe(self, your_iframe):
        self.base_name_iframe_window(your_iframe)
    """退出iframe标签"""
    def page_top_quit_iframe(self):
        self.base_quit_all_iframe()
    """点击会员管理"""
    def page_top_click_manage(self):
        self.base_click(self.vip_manage)
    """点击充值和提现"""
    def page_top_click_button(self):
        self.base_click(self.top_button)
    """点击添加申请"""
    def page_top_add_apply(self):
        self.base_click(self.add_apply)
    """输入会员姓名"""
    def page_top_input_name(self,your_name):
        self.base_input_massage(self.vip_name,your_name)
    """输入金额"""
    def page_top_money(self,your_money):
        self.base_input_massage(self.money,your_money)
    """选择支付方式下拉框"""
    def page_top_pay_select(self,your_select):
        return self.base_drop_down_menu(self.pay_select,your_select)
    """选择类型充值"""
    def page_top_up(self):
        self.base_click(self.top_up)
    """选择类型提现"""
    def page_top_with_draw(self):
        self.base_click(self.with_draw)
    """选择到款状态单选框"""
    def page_top_to_state(self):
        self.base_click(self.to_state)
    """点击确定"""
    def page_top_click_sure(self):
        self.base_click(self.sure)
    """获取文本"""
    def page_top_get_text(self):
        return self.base_get_text(self.text)
    """关闭"""
    def page_top_quit(self):
        self.base_quit_web()
if __name__ == '__main__':
    p1 = PageVipTopUp(create_loading_browser())
    p1.page_top_open_web()
    p1.page_top_iframe(0)
    p1.page_top_click_manage()
    p1.page_top_click_button()
    p1.page_top_quit_iframe()
    # 进入2层
    p1.page_top_iframe('main-frame')
    # 点击添加申请
    p1.page_top_add_apply()
    # 输入会员名
    p1.page_top_input_name('123')
    # 输入金额
    p1.page_top_money('600')
    # 支付方式下拉框
    result = p1.page_top_pay_select('余额支付')
    # 类型: 充值
    # p1.page_top_up()
    # 类型: 提现
    p1.page_top_with_draw()
    # 到款状态
    p1.page_top_to_state()
    # 点击确定
    p1.page_top_click_sure()
    time.sleep(15)
    # 获取文本
    print(p1.page_top_get_text())
    # 关闭
    # p1.page_top_quit()